package com.example.aninterface;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

public class WeChatAdapter extends ArrayAdapter<WeChat> {
    private int resourceId;
    public WeChatAdapter(Context context, int textViewResourceId, List<WeChat>objects){
        super(context,textViewResourceId,objects);
        resourceId = textViewResourceId;
    }

    @Override
    public View getView(int position,  View convertView,  ViewGroup parent) {
        WeChat wechat = getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
        ImageView wechat_img = (ImageView)view.findViewById(R.id.wechat_img);
        TextView wechat_name = (TextView)view.findViewById(R.id.wechat_name);
        wechat_img.setImageResource(wechat.getImageId());
        wechat_name.setText(wechat.getName());
        return view;
    }
}
